/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Latihan;

/**
 *
 * @author Edhi
 */
public class JawabanSoal1 {
	public static void main(String[] args){
		Integer total = 0;
		Integer average = 0;
		int maxLength = 20;

		for(int idx=0; idx<args.length; idx++){
			StringBuilder sb = new StringBuilder();

			for(int x=0; x < maxLength - args[idx].length(); x++){
				sb.append(" ");
			}
			sb.append(args[idx]);

			System.out.println(sb.toString());

			//proses menghitung nilai sebelumnya ditambah nilai dari argument
			total += Integer.parseInt(args[idx]);
			average += Integer.parseInt(args[idx]) / args.length;
		}

		//print separator
		System.out.println("====================");

		//String builder untuk total
		StringBuilder sbTotal = new StringBuilder();
		for(int x=0; x < maxLength - total.toString().length(); x++){
			sbTotal.append(" ");
		}
		sbTotal.append(total.toString());

		//String builder untuk average
		StringBuilder sbAvg = new StringBuilder();
		for(int x=0; x < maxLength - average.toString().length(); x++){
			sbAvg.append(" ");
		}
		sbAvg.append(average.toString());

		System.out.println(sbTotal.toString());
		System.out.println(sbAvg.toString());

	}
}

